/*
 Suggested new location: d:\test\mytcp\include\net\ip.h
 After restructuring:
  - move this header to include/net/ip.h
  - place implementations into src/net/
  - update build system to add include/ into include path
*/

#ifndef MYTCP_NET_IP_H
#define MYTCP_NET_IP_H

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*ip_payload_cb)(const uint8_t* payload, size_t len, uint32_t src_ip, uint16_t src_port, void* ctx);

int ip_init(void* netif_handle, uint32_t src_ip, const uint8_t src_mac[6]);
int ip_send_udp(uint32_t dst_ip, uint16_t dst_port, uint16_t src_port, const uint8_t* payload, size_t len);
int ip_send_tcp(uint32_t dst_ip, uint16_t dst_port, uint16_t src_port, const uint8_t* tcp_segment, size_t seg_len);
int ip_register_udp_cb(ip_payload_cb cb, void* ctx);
int ip_register_tcp_cb(void (*cb)(const uint8_t*, size_t, uint32_t, uint16_t, void*), void* ctx);

int ip_input(const uint8_t* pkt, size_t len);

#ifdef __cplusplus
}
#endif

#endif // MYTCP_NET_IP_H
